package com.garlicts.framework.crawler;

import java.util.Map;

public class CrawlerHttpRequest {

	// 爬取的Url
	private String url;
	
	// 搜索的关键字
	private String key;
	
	// request headers
	private Map<String,String> requestHeaderMap;
	
	// 代理ip:port
	private String proxyAddress;

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Map<String, String> getRequestHeaderMap() {
		return requestHeaderMap;
	}

	public void setRequestHeaderMap(Map<String, String> requestHeaderMap) {
		this.requestHeaderMap = requestHeaderMap;
	}

	public String getProxyAddress() {
		return proxyAddress;
	}

	public void setProxyAddress(String proxyAddress) {
		this.proxyAddress = proxyAddress;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}
	
	public static Builder builder() {
		return new Builder();
	}
	
	private CrawlerHttpRequest(Builder builder) {
		this.url = builder.url;
		this.key = builder.key;
		this.requestHeaderMap = builder.requestHeaderMap;
		this.proxyAddress = builder.proxyAddress;
	}
	
	public static class Builder {
		
		// 爬取的Url
		private String url;
		
		// 搜索的关键字
		private String key;
		
		// request headers
		private Map<String,String> requestHeaderMap;
		
		// 代理ip:port
		private String proxyAddress;
		
		public Builder setUrl(String url) {
			this.url = url;
			return this;
		}
		
		public Builder setKey(String key) {
			this.key = key;
			return this;
		}
		
		public Builder setRequestHeaderMap(Map<String,String> requestHeaderMap) {
			this.requestHeaderMap = requestHeaderMap;
			return this;
		}
		
		public Builder setProxyAddress(String proxyAddress) {
			this.proxyAddress = proxyAddress;
			return this;
		}
		
		public CrawlerHttpRequest build() {
			return new CrawlerHttpRequest(this);
		}
		
	}
	
}
